<script setup lang="ts">
import ApiApp from "@/api/app";
import useFetch from "@/hooks/useFetch";
import Taro, { useRouter } from "@tarojs/taro";

const { params } = useRouter();

const { data } = useFetch<{
  list: [
    {
      title: string;
      content: string;
    }
  ];
}>(ApiApp.getContent, {
  immediate: true, // 需要去掉
  defaultParams: {
    category: +(params.category || 1),
    type: +(params.type || 0),
  },
  onSuccess({ list }) {
    Taro.setNavigationBarTitle({ title: list[0].title });
  },
});

</script>

<template>
  <view class="p-3 h-screen overflow-auto">
    <rich-text :nodes="data?.list[0].content" />
  </view>
</template>
